<?php

namespace App\Http\Controllers;

use App\Services\ApplicantService;
use App\Services\ThirdPartyService;
use Illuminate\Http\Request;
use App\Classes\ThirdOauth\Facades\Socialite;

class HomeController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
//    public function __construct()
//    {
//        $this->middleware('auth');
//    }

    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        return view('home');
    }

    public function confirmEmail(Request $request)
    {
        $email = $request->input('email','');
        return view('confirm_email',[
            'email'=>$email
        ]);
    }

    public function googlePage(ApplicantService $applicantService)
    {
        $rs = $applicantService->getUserInfo();
        dd($rs);
        return view('google');
    }

    //第三方登录
    public function thirdLogin(Request $request, ThirdPartyService $partyService)
    {
        $type = $request->input('type','');
        $path = $request->input('path');
//        $this->validate($request, [
//            'type' => 'required|in: facebook,twitter,google',
//            'path' => 'required|string'
//        ]);
//        $url = array_get($request->session()->all(),'_previous.url');
//        dd($url);
        return $partyService->thirdOauthRedirect($type,$path);
    }

}
